﻿<UserControl
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
			xmlns:con="clr-namespace:Q2Q.Controls" 
			x:Class="Controls.TimeSpanIncrementer"
             mc:Ignorable="d"
			 x:Name="ThisControl"
             d:DesignHeight="22" Height="22" HorizontalAlignment="Center">
	<UserControl.Resources>
		<Style TargetType="TextBlock">
			<Setter Property="Foreground" Value="{DynamicResource TextForeground2}"/>
			<Setter Property="Background" Value="{DynamicResource NumericalIncrementer.Static.Background}" />
		</Style>
		<Style TargetType="Border">
			<Setter Property="BorderBrush" Value="{DynamicResource ComboBox.Static.Editable.Border}" />
			<Setter Property="BorderThickness" Value="1" />
			<Style.Triggers>
				<Trigger Property="IsEnabled" Value="False">
					<Setter Property="BorderBrush" Value="{x:Null}" />
					<Setter Property="Opacity" Value="1" />
				</Trigger>
			</Style.Triggers>
		</Style>
		<Style TargetType="TextBox" BasedOn="{StaticResource TextBoxOverride}">
			<Setter Property="BorderThickness" Value="1" />
			<Setter Property="BorderBrush" Value="{x:Null}" />
			<Setter Property="Height" Value="Auto" />
			<Setter Property="VerticalContentAlignment" Value="Center" />
			<Setter Property="HorizontalContentAlignment" Value="Center" />
			<Setter Property="Padding" Value="0" />
			<Setter Property="IsUndoEnabled" Value="False" />
			<Setter Property="MaxLines" Value="1" />
			<Setter Property="FontSize" Value="{Binding FontSize, ElementName=ThisControl}" />
			<Setter Property="Margin" Value="0,1" />
			<Style.Triggers>
				<Trigger Property="con:IsSelectedForWriting.IsSelectedForWriting" Value="True">
					<Setter Property="BorderThickness" Value="1" />
					<Setter Property="BorderBrush" Value="{DynamicResource ComboBox.MouseOver.Border}" />
				</Trigger>
				<Trigger Property="IsEnabled" Value="False">
					<Setter Property="BorderThickness" Value="0" />
					<Setter Property="Padding" Value="1" />
				</Trigger>
			</Style.Triggers>
		</Style>
	</UserControl.Resources>
	<Grid>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="5*" />
			<ColumnDefinition Width="Auto" MaxWidth="15" MinWidth="15" />
		</Grid.ColumnDefinitions>
		<Border IsEnabled="{Binding IsEnabled, ElementName=ThisControl}">
			<StackPanel Orientation="Horizontal">
				<TextBox x:Name="Hours" IsEnabled="{Binding IsEnabled, ElementName=ThisControl}" con:IsSelectedForWriting.IsSelectedForWriting="{Binding HoursFocused, ElementName=ThisControl}" Text="{Binding TimeHours, ElementName=ThisControl, StringFormat=\{0:00\}}" MaxLength="3" />
				<TextBlock Text=":" />
				<TextBox x:Name="Minutes" IsEnabled="{Binding IsEnabled, ElementName=ThisControl}" con:IsSelectedForWriting.IsSelectedForWriting="{Binding MinutesFocused, ElementName=ThisControl}" Text="{Binding TimeMinutes, ElementName=ThisControl, StringFormat=\{0:00\}}" MaxLength="2" />
				<TextBlock Text=":" />
				<TextBox x:Name="Seconds" IsEnabled="{Binding IsEnabled, ElementName=ThisControl}" con:IsSelectedForWriting.IsSelectedForWriting="{Binding SecondsFocused, ElementName=ThisControl}" Text="{Binding TimeSeconds, ElementName=ThisControl, StringFormat=\{0:00\}}" MaxLength="2" />
				<TextBlock Text="." />
				<TextBox x:Name="Tenths" IsEnabled="{Binding IsEnabled, ElementName=ThisControl}" con:IsSelectedForWriting.IsSelectedForWriting="{Binding TenthsFocused, ElementName=ThisControl}" Text="{Binding TimeTenths, ElementName=ThisControl, StringFormat=\{0:000\}}" MaxLength="3" />
			</StackPanel>
		</Border>
		<Grid Grid.Column="8">
			<Grid.RowDefinitions>
				<RowDefinition Height="1*" />
				<RowDefinition Height="1*" /> 
			</Grid.RowDefinitions>
			<RepeatButton Style="{StaticResource RepeatButton}" Grid.Row="0" x:Name="Incrementer" Click="IncrementValue" Padding="1" Visibility="{Binding IsEnabled, ElementName=ThisControl, Converter={StaticResource BooleanToVisibilityConverter}}">
				<Path x:Name="ArrowTop" Data="M0,4C0,4 0,6 0,6 0,6 3.5,2.5 3.5,2.5 3.5,2.5 7,6 7,6 7,6 7,4 7,4 7,4 3.5,0.5 3.5,0.5 3.5,0.5 0,4 0,4z" Fill="{Binding Foreground, ElementName=Incrementer}" Margin="0" Stretch="Uniform" MaxWidth="18" MaxHeight="15"/>
			</RepeatButton>
			<RepeatButton Style="{StaticResource RepeatButton}" Grid.Row="1" x:Name="Decrementer" Click="DecrementValue" Padding="1" Visibility="{Binding IsEnabled, ElementName=ThisControl, Converter={StaticResource BooleanToVisibilityConverter}}">
				<Path x:Name="ArrowBottom" Data="M0,2.5C0,2.5 0,0.5 0,0.5 0,0.5 3.5,4 3.5,4 3.5,4 7,0.5 7,0.5 7,0.5 7,2.5 7,2.5 7,2.5 3.5,6 3.5,6 3.5,6 0,2.5 0,2.5z" Fill="{Binding Foreground,ElementName=Decrementer}" Margin="0" Stretch="Uniform" MaxWidth="18" MaxHeight="15"/>
			</RepeatButton>
		</Grid>
	</Grid>
</UserControl>